package com.zzw.thread;

/**
 * Created by Administrator on 2019/6/29.
 */
public class MoneyThread extends Thread {

    private MoneyVo money;
    private static Object object = new Object();

    public MoneyThread(MoneyVo money){
        this.money = money;
    }

    public MoneyThread(){
    }

    @Override
    public void run() {
       /* synchronized (money){
            money.setMoney(money.getMoney() + 1);
        }*/
        money.add();
        System.out.println(Thread.currentThread().getName() + "------" + money.getMoney());
    }

    public static void main(String[] args) throws InterruptedException {
        MoneyVo m = new MoneyVo(0);
        new MoneyThread(m).start();
        new MoneyThread(m).start();
        Thread.sleep(1000);
    }
}
